<form class="form-inline" method="get">
    <div class="form-group col-xs-3">
        <div class="col-xs-12">
            <select class="form-control" name="status" id="status">
                <option value=''   {if isset($param['status']) && $param['status'] === ''}selected{/if} >全部</option>
                <option value='0'  {if isset($param['status']) && $param['status'] === '0'}selected{/if}>未处理</option>
                <option value='1' {if isset($param['status']) && $param['status'] === '1'}selected{/if}>已通过</option>
                <option value='2' {if isset($param['status']) && $param['status'] === '2'}selected{/if}>已拒绝</option>
            </select>
        </div>
    </div>
    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            <button type="submit" class="btn btn-success">
                确认搜索
            </button>
        </div>
    </div>
</form>
<hr>
<table class="table table-striped">
    <thead>
    <tr>
        <td>ID</td>
        <td>用户名</td>
        <td>身份证号</td>
        <td>实名姓名</td>
        <td>身份证正面</td>
        <td>身份证反面</td>
        <td>处理状态</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    {volist name="list" id="item"}
    <tr>
        <td>{$item.id}</td>
        <td>
            <p>{$item.username}</p>
        </td>
        <td>{$item.selfcard}</td>
        <td>{$item.realname}</td>
        <td>
            {if condition="$item['status'] == 0" } <label style='color:#ff9797'>未处理</label>{/if}
            {if condition="$item['status'] == 1" }<label style='color:#666'>已通过</label>{/if}
            {if condition="$item['status'] == 2" }<label style='color:#666'>已拒绝</label>{/if}
        </td>

        <td>
            <img src="{$item.card_1}" alt="" style="width: 120px; height: 100px" onclick="big('{$item.card_1}')">
        </td>

        <td>
            <img src="{$item.card_2}" alt="" style="width: 120px; height: 100px" onclick="big('{$item.card_2}')">
        </td>
        <td>
            <div class="btn-group">

                {if condition="$item['status'] == 0" }
                <button type="button" class="btn btn-default" onclick="solve('{$item.id}', 1)">
                    通过
                </button>
                <button type="button" class="btn btn-default" onclick="solve('{$item.id}', 2)">
                    拒绝
                </button>
                {/if}
                {if condition="$item['status'] >= 1" }<label style='color:#666'>已处理</label>{/if}
            </div>
        </td>
    </tr>
    {/volist}
    </tbody>
</table>

<div class="row">
    <div class="col-xs-12" style="text-align: right;">
        {$list->render()}
    </div>
</div>
<script src="__PUBLIC__/vendors/select2/js/select2.min.js"></script>
<script type="application/javascript">
    function big(src){
        layer.photos({
            photos: { "data": [{"src": src}] }
            ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
        })
    }


    $(function () {
        $("#status").select2({
            placeholder: "处理状态",
            allowClear: true
        });
        $("#type").select2({
            placeholder: "工单类型",
            allowClear: true
        });
    });
    
    function tj(id, t, tips) {
        $.ajax({
            url:"{:url('solveapply')}",
            data:{
                "id":id,
                "t":t,
                'remark':tips
            },
            type:"post",
            dataType:"json",
            success:function (res) {
                layer.msg(res.info);
                setTimeout(function () {
                    location.reload()
                }, 666)
            }
        })
    }
    
    function solve(id, t) {
        if(t == 1){
            layer.confirm("确定处理此记录？", function (res) {
                tj(id, t, '')
            })
        }else{
            layer.prompt({title: '输入拒绝原因，并确认', formType: 2}, function (res, index) {
                if(res){
                    layer.close(index);
                    tj(id, t, res)
                }else{
                    layer.msg("拒绝原因不能为空");
                }
            })
        }
    }
</script>
